//
//  WNNetwork.h
//  Whatnet_iOS
//
//  Created by Bill on 2019/4/16.
//  Copyright © 2019 什么网络. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class NSURLSessionDataTask, AFHTTPSessionManager, SAViewController;



#define kWNParameterType   @"WNParameterType"
typedef NS_ENUM(NSInteger, WNParameterType){
    WNParameterTypeJson,
    WNParameterTypeKeyValue
};

typedef void (^WNRequestSuccess)(id responseObject);
typedef void (^WNRequestFailure)(NSString *code,NSString *mes);//code为后台返回的错误代码

@interface WNNetwork : NSObject

@property (nonatomic, strong) AFHTTPSessionManager *networkManager;

+ (id)startEngine;
+ (void)restart;

/// Get 请求
+ (NSURLSessionDataTask *)GET:(NSString *)urlString para:(nullable id)para success:(WNRequestSuccess)success;
+ (NSURLSessionDataTask *)GET:(NSString *)urlString para:(nullable id)para success:(WNRequestSuccess)success failure:(WNRequestFailure)failure;
+ (NSURLSessionDataTask *)GET:(NSString *)urlString para:(nullable id)para success:(WNRequestSuccess)success message:(nullable NSString *)message;
+ (NSURLSessionDataTask *)GET:(NSString *)urlString para:(nullable id)para success:(WNRequestSuccess)success failure:(WNRequestFailure _Nullable)failure message:(nullable NSString *)message controller:(nullable UIViewController * )controller;
/// Post 请求
+ (NSURLSessionDataTask *)POST:(NSString *)urlString para:(id)para success:(WNRequestSuccess)success;
+ (NSURLSessionDataTask *)POST:(NSString *)urlString para:(id)para success:(WNRequestSuccess)success failure:(WNRequestFailure)failure;
+ (NSURLSessionDataTask *)POST:(NSString *)urlString para:(id)para success:(WNRequestSuccess)success message:(NSString *)message;
+ (NSURLSessionDataTask *)POST:(NSString *)urlString para:(id)para success:(WNRequestSuccess)success message:(NSString *)message controller:(UIViewController *)controller;

/// 错误处理
+ (BOOL)filterResponse:(id)response task:(NSURLSessionDataTask *)task;
+ (void)responseError:(NSError *)error task:(NSURLSessionDataTask *)task;

/// 网络状态
+ (NSString *)networkStatus;

+ (void)refreshRequestHeader;
//Emoji表情过滤
+ (BOOL)stringContainsEmoji:(NSString *)string;
+(NSString*)dataTOjsonString:(id)object;
@end



NS_ASSUME_NONNULL_END
